import pytesseract,os
from PIL import Image

code_file = r"E:\python\code_test\code.jpg"

image_res = Image.open(code_file)
new_img = image_res.convert('L')
new_img.save("code1.jpg")